<?php

class Server extends Obj {
	private static $me = false;
	
	public static function _() {
		Server::$me = DB::load(Config::$SERVERID);
		if(Server::$me == false) {
			Server::$me = new Server();
			DB::save(Server::$me);
		}
		return Server::$me;
	}

	public $name;
	private $games = array();

	private function Server() {
		parent::__construct(Config::$SERVERID);
	}

	public function addGames($numOfGames, $gameType){
		if(DB::checkServer()){
			for($i=0;$i<$numOfGames;$i++){
				$gm = new $gameType();
				$id = DB::save($gm);
				array_push($this->games, $id);
			}
		}
	}

	public function gameList(){
		$ret = array();
		foreach($this->games as $k => $v) {
			$ret[$v] = DB::load($v);
		}
		return $ret;
	}
}

?>